package com.example.as_sum.activity;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.NotificationCompat;
import android.view.View;

import com.example.as_sum.R;
import com.example.as_sum.application.DownService;

import butterknife.OnClick;

public class NotificationCompatActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getContentId() {
        return R.layout.activity_notification_compat;
    }

    NotificationCompat.Builder mBuilder;
    NotificationManager mManager;
    PendingIntent mPendingIntent;

    @Override
    public void initView() {
        mManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        //启动一个Service
        mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, PalyActivity.class), 0);
        mBuilder = new NotificationCompat.Builder(this);
        mBuilder.setContentTitle("新消息来了");
        mBuilder.setContentText("晚上一起吃饭吧");
        mBuilder.setSmallIcon(R.drawable.logo);

    }
    @OnClick({R.id.notification_btn1, R.id.notification_btn2, R.id.notification_btn3,
            R.id.notification_btn4, R.id.notification_btn5})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.notification_btn1:
                mBuilder.setContentIntent(mPendingIntent);
                mManager.notify(100, mBuilder.build());
                break;
            case R.id.notification_btn2:
                mBuilder.setContentTitle("新消息来了2");
                mManager.notify(100,mBuilder.build());
                break;
            case R.id.notification_btn3:
                mManager.cancel(100);
                break;
            case R.id.notification_btn4:
                mPendingIntent=PendingIntent.getService(this, 0, new Intent(this, DownService.class), 0);
                mBuilder.setAutoCancel(true);
                mBuilder.setContentIntent(mPendingIntent);
                mManager.notify(101, mBuilder.build());
                break;
            case R.id.notification_btn5:
//                mPendingIntent=PendingIntent.getBroadcast(this, 0, new Intent(this, DownService.class), 0);
//                mBuilder.setContentIntent(mPendingIntent);
//                mManager.notify(100, mBuilder.build());
                break;
        }
    }
    @Override
    public void addListener() {

    }

    @Override
    public void loadData() {

    }

    @Override
    public Handler getHandler() {
        return null;
    }


}
